package com.yjc.hire.mq;


import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//死信队列配置
@Configuration
public class RabbitMqSMSConfig_Dead {
    public static final String SMS_EXCHANGE_DEAD = "sms_exchange_dead";

    public static final String SMS_QUEUE_DEAD = "sms_queue_dead";

    public static final String ROUTING_KEY_SNS_SEND_Dead = "dead.sms.display";

    @Bean(SMS_EXCHANGE_DEAD)
    public Exchange smsExchange() {
        return ExchangeBuilder.topicExchange(SMS_EXCHANGE_DEAD)
                .durable(true)
                .build();
    }

    @Bean(SMS_QUEUE_DEAD)
    public Queue smsQueue() {
      return QueueBuilder.durable(SMS_QUEUE_DEAD).build();
    }

    @Bean
    public Binding smsDeadBinding(@Qualifier(SMS_EXCHANGE_DEAD) Exchange exchange, @Qualifier(SMS_QUEUE_DEAD) Queue queue) {
        return BindingBuilder.bind(queue)
                .to(exchange)
                .with("dead.sms.*")
                .noargs();
    }
}
